package iscas.reserve.Controller;


import iscas.reserve.clients.DeliveryFeignClient;
import iscas.reserve.clients.NotificationFeignClient;
import iscas.reserve.common.CustomResult;
import iscas.reserve.dto.DeliveryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/reserve")
public class ReserveController {
    @Autowired
    RestTemplate restTemplate;
    @Autowired
    private NotificationFeignClient notificationFeignClient;
    @Autowired
    private DeliveryFeignClient deliveryFeignClient;
    // 查看库存
    @GetMapping("/getReserve")
    public CustomResult getReserve(@RequestParam String orderContent) {
        // 请求通知服务
        notificationFeignClient.toNotification();
        // 请求配送服务 post请求
        DeliveryDTO deliveryDTO = new DeliveryDTO("北京","北京","海淀","中关村南四街","中国科学院软件研究所" ,"粥隔离","18888888888");
        deliveryFeignClient.toDelivery(deliveryDTO);
        return new CustomResult(20000, "库存充足", null);
    }
}